From: Florian Müllner Date: Mon, 25 Jan 2021 11:32:26 +0000 (+0100) Subject: screenshot: Return error if stream creation failed X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~555 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0efa82acf02ffbb017b5c58e9d954cfc1aea3f00;p=gnome-shell.git screenshot: Return error if stream creation failed When we fail for some reason to open a stream to write the screenshot to, we currently return `false` to the sender. That's not wrong, but doesn't provide any hints on what caused the failure, so return the underlying error instead. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3618 Part-of: --- diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js index 29cf7c897..05120e1a2 100644 --- a/js/ui/screenshot.js +++ b/js/ui/screenshot.js @@ -108,22 +108,24 @@ var ScreenshotService = class { let stream = file.replace(null, false, Gio.FileCreateFlags.NONE, null); return [stream, file]; } catch (e) { - invocation.return_value(GLib.Variant.new('(bs)', [false, ''])); + invocation.return_gerror(e); return [null, null]; } } + let err; for (let file of this._resolveRelativeFilename(filename)) { try { let stream = file.create(Gio.FileCreateFlags.NONE, null); return [stream, file]; } catch (e) { + err = e; if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS)) break; } } - invocation.return_value(GLib.Variant.new('(bs)', [false, ''])); + invocation.return_gerror(err); return [null, null]; }